/*
 * @Author: szx
 * @Date: 2021-12-15 14:43:43
 * @LastEditTime: 2021-12-15 14:46:58
 * @Description:
 * @FilePath: \leetcode\400-499\429\429.js
 */
/**
 * @param {Node|null} root
 * @return {number[][]}
 */
var levelOrder = function (root) {
    const res = [];
    if (!root) return res;
    const que = [];
    que.push(root);
    while (que.length) {
        const length = que.length;
        const arr = [];
        for (let i = 0; i < length; i++) {
            const tmp = que.shift();
            arr.push(tmp.val);
            for (let j = 0; j < tmp.children.length; j++) {
                if (tmp.children[j]) que.push(tmp.children[j]);
            }
        }
        res.push(arr);
    }
    return res;
};
